﻿<ribbon:RibbonWindow x:Class="UserAdministration"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
		Title="User Administration"
		x:Name="UserAdministration"
		 Width="Auto" Height="Auto" Icon="../../images/Main/keys.png" SizeToContent="WidthAndHeight"
					 xmlns:local="clr-namespace:ATS.UI.WPF" MaxHeight="450">

	<ribbon:RibbonWindow.Resources>
		<local:HalfValueConverter x:Key="HalfValue" />
		<local:ImageConverter  x:Key="ImageConverter" />
		<Style TargetType="Label" x:Key="MyLabel">
			<Setter Property="Foreground" Value="White" />
			<Setter Property="FontSize" Value="50"/>
			<Setter Property="Background" Value="LightBlue" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Label}">
						<Border BorderThickness="{TemplateBinding BorderThickness}"
								BorderBrush="{TemplateBinding BorderBrush}"
								Padding="{TemplateBinding Padding}"
								SnapsToDevicePixels="true">
							<Grid>
								<Rectangle Fill="{TemplateBinding Background}">
									<Rectangle.OpacityMask>
										<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
											<GradientStop Color="#80000000" Offset="0.0" />
											<GradientStop Color="#E6000000" Offset="0.5" />
											<GradientStop Color="#80000000" Offset="1.0" />
										</LinearGradientBrush>
									</Rectangle.OpacityMask>
								</Rectangle>
								<ContentPresenter
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
									RecognizesAccessKey="True"
									SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground"
										Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<Style x:Key="{x:Type ListBoxItem}" TargetType="{x:Type ListBoxItem}">
			<Setter Property="OverridesDefaultStyle" Value="true" />
			<Setter Property="Background" Value="Transparent" />
			<Setter Property="BorderBrush" Value="Transparent" />
			<Setter Property="BorderThickness" Value="1" />
			<Setter Property="HorizontalContentAlignment" Value="Stretch" />
			<Setter Property="VerticalContentAlignment" Value="Center" />
			<Setter Property="Padding" Value="3" />
			<Setter Property="Opacity" Value=".80" />
			<Setter Property="LayoutTransform">
				<Setter.Value>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
				</Setter.Value>
			</Setter>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ListBoxItem}">
						<Border Background="{TemplateBinding Background}" 
								BorderBrush="{TemplateBinding BorderBrush}" 
								BorderThickness="{TemplateBinding BorderThickness}" 
								Padding="{TemplateBinding Padding}">
							<ContentPresenter x:Name="ContentSite" 
											  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
											  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsSelected" Value="true">
								<Setter Property="Background">
									<Setter.Value>
										<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
											<LinearGradientBrush.GradientStops>
												<GradientStop Offset="0" Color="LightGray"/>
												<GradientStop Offset="1" Color="DarkGray"/>
											</LinearGradientBrush.GradientStops>
										</LinearGradientBrush>
									</Setter.Value>
								</Setter>
								<Setter Property="BorderBrush" Value="Silver" />
								<Setter Property="Opacity" Value="1"/>
							</Trigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="true" />
									<Condition Property="Selector.IsSelectionActive" 
											   Value="false" />
								</MultiTrigger.Conditions>
								<Setter Property="Background" Value="LightGray" />
								<Setter Property="BorderBrush" Value="DarkGray" />
							</MultiTrigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Style.Triggers>
				<Trigger Property="IsEnabled" Value="false">
					<Setter Property="Foreground" Value="Gray" />
				</Trigger>
				<EventTrigger RoutedEvent="Mouse.MouseEnter">
					<EventTrigger.Actions>
						<BeginStoryboard>
							<Storyboard>
								<!--DoubleAnimation Duration="0:0:0.0"                                                 
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
												 From="1" To="1.125"/>
									<DoubleAnimation Duration="0:0:0.0"                                                 
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
												 From="1" To="1.125"/-->
								<DoubleAnimation Duration="0:0:0.2"
												 Storyboard.TargetProperty="Opacity"
												 To="1.0" />
							</Storyboard>
						</BeginStoryboard>
					</EventTrigger.Actions>
				</EventTrigger>
				<EventTrigger RoutedEvent="Mouse.MouseLeave">
					<EventTrigger.Actions>
						<BeginStoryboard>
							<Storyboard>
								<!--DoubleAnimation Duration="0:0:0.0"
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleY)"
												 From="1.125" To="1"/>
									<DoubleAnimation Duration="0:0:0.0"                                                 
												 Storyboard.TargetProperty="(ListBoxItem.LayoutTransform).(ScaleTransform.ScaleX)"
												 From="1.125" To="1"/-->
								<DoubleAnimation Duration="0:0:0.2"
												 Storyboard.TargetProperty="Opacity" />
							</Storyboard>
						</BeginStoryboard>
					</EventTrigger.Actions>
				</EventTrigger>
			</Style.Triggers>
		</Style>
		<DataTemplate x:Key="listBoxTemplate">
			<Border BorderBrush="Blue"
					BorderThickness="1"
					CornerRadius="1"
					Margin="1">
				<StackPanel Orientation="Horizontal">
					<StackPanel>

						<TextBlock Text="{Binding Username}" 
							   Foreground="Green" 
							   FontWeight="Bold"
								   x:Name="username"/>
						<StackPanel Orientation="Horizontal">
							<TextBlock Margin="2">Account Locked =</TextBlock >
							<TextBlock Text="{Binding AccountLocked}" Name="textblockIsLocked"
								   Margin="2"></TextBlock>

						</StackPanel>
					</StackPanel>
					<Image Source="{Binding Converter={StaticResource ImageConverter}}"                           
						   Width="15"
						   Height="15"
						   Margin="10,2,2,2"
						   HorizontalAlignment="Right"
						   Name="userimage"
						   >
					</Image>
				</StackPanel>
			</Border>
		</DataTemplate>
	</ribbon:RibbonWindow.Resources>

	<Grid x:Name="mainGrid">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>

		<ribbon:Ribbon x:Name="Ribbon">
			<ribbon:Ribbon.ApplicationMenu>
				<ribbon:RibbonApplicationMenu Visibility="Collapsed" >
				</ribbon:RibbonApplicationMenu>
			</ribbon:Ribbon.ApplicationMenu>
			<ribbon:Ribbon.QuickAccessToolBar>
				<ribbon:RibbonQuickAccessToolBar Visibility="Collapsed"></ribbon:RibbonQuickAccessToolBar>
			</ribbon:Ribbon.QuickAccessToolBar>

			<ribbon:RibbonTab x:Name="UserSettingsTab"
							  
							  Header="User Settings">
				<ribbon:RibbonGroup x:Name="Actions"
									Header="Actions">
					<ribbon:RibbonButton x:Name="buttonNew"
										 LargeImageSource="../../images/actions/ctrladd.png"
										 Label="New" />                    
					<ribbon:RibbonButton x:Name="buttonRefresh"
										 LargeImageSource="../../images/actions/Refresh-64.png"
										 Label="Refresh" />
					<ribbon:RibbonButton x:Name="buttonSave"
										 LargeImageSource="../../images/actions/ctrlsave.png"
										 Label="Save" />
					<ribbon:RibbonButton x:Name="buttonDelete"
										 LargeImageSource="../../images/actions/delete.png"
										 Label="Delete" />
				</ribbon:RibbonGroup>
			</ribbon:RibbonTab>
		</ribbon:Ribbon>
		<Grid Grid.Row="1">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"></ColumnDefinition>
				<ColumnDefinition Width="*"></ColumnDefinition>
			</Grid.ColumnDefinitions>
			<Expander Width="Auto" ExpandDirection="Right" HorizontalAlignment="Right" Grid.Column="0" Name="ExpanderList">
				<Expander.Header>
					<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,0" Width="Auto" x:Name="ExpanderText">
						<TextBlock.LayoutTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1"/>
								<SkewTransform AngleX="0" AngleY="0"/>
								<RotateTransform Angle="90"/>
								<TranslateTransform X="0" Y="0"/>
							</TransformGroup>
						</TextBlock.LayoutTransform>
						<TextBlock.RenderTransform>
							<TransformGroup>
								<ScaleTransform ScaleX="1" ScaleY="1"/>
								<SkewTransform AngleX="0" AngleY="0"/>
								<RotateTransform Angle="0"/>
								<TranslateTransform X="0" Y="0"/>
							</TransformGroup>
						</TextBlock.RenderTransform>
					</TextBlock>
				</Expander.Header>

				<Border Name="borderHeader" BorderBrush="Gray" 
						BorderThickness="1,1,1,1" 
						CornerRadius="6,6,6,6">
					<Grid Name="gridListbox">
						<Grid.RowDefinitions>
							<RowDefinition Height="auto"></RowDefinition>
							<RowDefinition></RowDefinition>
						</Grid.RowDefinitions>
						<StackPanel Orientation="Horizontal" 
									Background="Aquamarine"
									VerticalAlignment="Top"
									Margin="2" Grid.Row="0">
							<TextBox MinHeight="10" 
									 MinWidth="126"
									 Margin="2"
									 Name="searchBox">Search Users</TextBox>
						</StackPanel>
						<ListBox x:Name="listBoxUsers"    
								 Grid.Row="1"
								 VerticalAlignment="Top"
								 HorizontalContentAlignment="Stretch"
								 ItemContainerStyle="{DynamicResource ListBoxItem}" 
								 ItemTemplate="{StaticResource listBoxTemplate}" 
								 ItemsSource="{Binding}"></ListBox>
						<Control Grid.RowSpan="2"
								 x:Name="busyAnimation" 
								 Style="{StaticResource BusyAnimationStyle}"
								 Width="{Binding Path=ActualWidth, ElementName=listBoxUsers}" 
								 Height="{Binding Path=ActualHeight, ElementName=imagelistBoxUsers}" />
					</Grid>
					
				</Border>
				
			</Expander>
			
			<Border  Grid.Column="1" Name="borderHeaderRight" BorderBrush="Gray" 
				BorderThickness="1,1,1,1" 
									CornerRadius="6,6,6,6" >


				<Grid>
					<Grid Name="gridUserDetails">
						<Grid.RowDefinitions>
							<RowDefinition Height="auto"></RowDefinition>
							<RowDefinition Height="auto"></RowDefinition>
							<RowDefinition Height="auto"></RowDefinition>
							<RowDefinition Height="auto"></RowDefinition>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="auto"></ColumnDefinition>
							<ColumnDefinition Width="auto"></ColumnDefinition>
						</Grid.ColumnDefinitions>
						<Label Grid.Column="0" Grid.Row="0" Margin="5,10,5,10">Username</Label>
						<TextBox Grid.Column="1" Width="250" Margin="5,10,5,10" Grid.Row="0" Name="textboxUser" Style="{DynamicResource TextBoxStyle}" Text="{Binding ElementName=listBoxUsers, Path=SelectedItem.Username}" IsReadOnly="True"></TextBox>
						<Label Grid.Column="0" Grid.Row="1" Margin="5,10,5,10">Password</Label>
						<PasswordBox  Grid.Column="1" Width="250" Margin="5,10,5,10" Grid.Row="1" Name="passwordboxPassword" Password="password"></PasswordBox >
						<Label Grid.Column="0" Grid.Row="3" Margin="5,10,5,10" Visibility="Hidden">Password</Label>
						<TextBox Grid.Column="1" Width="250" Margin="5,10,5,10" Grid.Row="3" Name="textboxPassword" Visibility="Hidden"></TextBox>
						<Label Grid.Column="0" Grid.Row="2" Margin="5,10,5,10">Locked</Label>
						<CheckBox Grid.Column="1" Margin="5,10,5,10" Grid.Row="2" Name="cbLocked" VerticalAlignment="Center" IsChecked="{Binding ElementName=listBoxUsers, Path=SelectedItem.AccountLocked}"></CheckBox>
					</Grid>
				</Grid>
			</Border>
			<Border Name="mainOverlay" Grid.Column="1" CornerRadius="6,6,6,6">
				<DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="LightBlue">
					<DockPanel.OpacityMask >
						<LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,1">
							<GradientStop Color="#80000000" Offset="0.0" />
							<GradientStop Color="#E6000000" Offset="0.5" />
							<GradientStop Color="#80000000" Offset="1.0" />
						</LinearGradientBrush>
					</DockPanel.OpacityMask >

					<Label  VerticalAlignment="Center" HorizontalAlignment="Center" Style="{StaticResource MyLabel}">empty record</Label>

				</DockPanel>
			</Border>            
		</Grid>
		<Canvas Name="MyCanvas" Grid.Column="1"  Visibility="Collapsed" Grid.RowSpan="2" Grid.Row="0" >
			<Canvas.Background>
				<LinearGradientBrush StartPoint="0.5,1" EndPoint="0.5,1">
					<GradientStop Color="#80000000" Offset="0.0" />
					<GradientStop Color="#E6000000" Offset="0.5" />
					<GradientStop Color="#80000000" Offset="1.0" />
				</LinearGradientBrush>
			</Canvas.Background>
			<local:ucNewItem   x:Name="UcNewUser"  Width="250"
					 Height="125">
				<Canvas.Left>
					<MultiBinding Converter="{StaticResource HalfValue}">
						<Binding ElementName="MyCanvas" Path="ActualWidth" />
                        <Binding ElementName="UcNewUser" Path="ActualWidth" />
					</MultiBinding>
				</Canvas.Left>
				<Canvas.Top>
					<MultiBinding Converter="{StaticResource HalfValue}">
						<Binding ElementName="MyCanvas" Path="ActualHeight" />
                        <Binding ElementName="UcNewUser" Path="ActualHeight" />
					</MultiBinding>
				</Canvas.Top>

            </local:ucNewItem>
		</Canvas>
		<Control Grid.RowSpan="2"
								 x:Name="busyAnimationSaveAndDelete" 
								 Style="{StaticResource BusyAnimationStyle}"
								 Width="{Binding Path=ActualWidth, ElementName=mainGrid}" 
								 Height="{Binding Path=ActualHeight, ElementName=mainGrid}"
				 Visibility="Collapsed"/>
	</Grid>
</ribbon:RibbonWindow>
